package com.alkaid.manga.controller;

import com.alkaid.commons.controller.BaseController;
import com.alkaid.commons.entity.Manga;
import com.alkaid.commons.entity.MangaSource;
import com.alkaid.commons.utils.JsonResult;
import com.alkaid.manga.service.MangaDetailsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Kylin
 */
@RestController
@RequestMapping("api/manga")
public class MangaDetailsController extends BaseController {

    private final MangaDetailsService mangaDetailsService;

    public MangaDetailsController(MangaDetailsService mangaDetailsService) {
        this.mangaDetailsService = mangaDetailsService;
    }

    @GetMapping("/play/eq/{id}")
    public JsonResult<Manga> getNovelPlayByMangaDetailsId(@PathVariable Long id) {
        Manga manga = mangaDetailsService.getMangaDetailsWithDetailId(id);
        return new JsonResult<>(200, manga, "success");
    }

    /**
     * 漫画源
     *
     * @param id the id
     * @return the hot list
     */
    @GetMapping("/play/source/{id}")
    public JsonResult<List<MangaSource>> getSource(@PathVariable Long id) {
        List<MangaSource> txt = mangaDetailsService.getSource(id);
        return new JsonResult<>(200, txt, "success");
    }
}
